﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GameCoder.Model
{
    public class MacthItem
    {
        public Guid ID { get; set; }
        public string Name { get; set; }
        public PlayerItem PlayerA { get; set; }
        public PlayerItem PlayerB { get; set; }
        public IList<GameSetItem> Sets { get; set; }
        public int ScoreA { get; set; }
        public int ScoreB { get; set; }
        public bool Finished
        {
            get
            {
                if (Math.Max(ScoreA, ScoreB) >= 11 && Math.Abs(ScoreA - ScoreB) > 1)
                {
                    return true;
                }
                return false;
            }
        }
        public PlayerItem Winner
        {
            get
            {
                if (Finished)
                {
                    return ScoreA > ScoreB ? PlayerA : PlayerB;
                }
                return null;
            }
        }

    }
}
